package com.shop.cereshop.agent.param.user;

import cn.hutool.core.util.StrUtil;
import com.shop.cereshop.commons.config.RsaProperties;
import com.shop.cereshop.commons.utils.RsaUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @description: TODO
 * @author lx
 * @date 2025/11/14 11:46
 * @version 1.0
 */
@Data
@ApiModel(value = "UpdatePhoneDTO", description = "修改手机号参数")
public class UpdatePhoneDTO {
    @ApiModelProperty(value = "新手机号")
    private String phone;

    @ApiModelProperty(value = "新手机号验证码")
    private String verificationCode;

    @ApiModelProperty(value = "旧手机号验证码")
    private String oldVerificationCode;

    public UpdatePhoneDTO decrypt() throws Exception {
        UpdatePhoneDTO res = new UpdatePhoneDTO();
        if (StrUtil.isNotBlank(this.phone)) {
            res.setPhone(RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,this.phone));
        }
        res.setVerificationCode(this.verificationCode);
        res.setOldVerificationCode(this.oldVerificationCode);
        return res;
    }
}
